#!/bin/sh
#		ROOT CACHE PROGRAM
#	By Paul Balyoz <pab@rainbow.cse.nau.edu>  03/15/91
#

# Name of file to write the new root cache into
OUT="CACHEFILE"

# Front part of the name of the awk script we need to run
AWKSCR="CBAWKPATH"

# This must include the directory where "nslookup" lives
PATH=/usr/ucb:/bin:/usr/bin:/usr/etc:/usr/local/bin:/usr/com/bin
export PATH

# --------------------------------------------------------------------------

rm -f $OUT.older
if test -f $OUT.old; then
	mv $OUT.old $OUT.older
fi
if test -f $OUT; then
	mv $OUT $OUT.old
fi

echo ";" > $OUT
echo "; root.cache built by $USER@`hostname` on `date`" >> $OUT
echo "; Automatically built by cachebuild, any changes you make may go away." >> $OUT
echo ";" >> $OUT
echo "" >> $OUT

nslookup << EOF | awk -f $AWKSCR >> $OUT
set type=NS
root
.
EOF

err=$?
if test $err -ne 0; then
	echo "Call to nslookup failed."
	rm -f $OUT
fi
exit $err
